#include "OnlineExtendDevices.h"

#include "ExtendDevice.h"
#include"MachineDependents.h"

void OnlineExtendDevices::paint() {
    std::string content[4];

    resetStream();

    strStream << "extendDevice" << std::right << std::setw(4) << pageNum;// << std::setw(3)
    content[0] = strStream.str();

    ExtendDevicePtr extendDevicePtr;
    const ExtendDeviceWeakPtr* pExtendDevices = ExtendDeviceManagerSingleton::instance().getAllOnlineExtendDevices();

    const size_t num = computePageItems(MDConst::DEFAULT_CHANNEL_COUNT);
    size_t index = 0;
    for (size_t i = 0; i < num; ++i) {
        resetStream();
        index = mmultiPageNo * CONTENT_LINE_PER_PAGE + i;
        strStream << index << ':';

        extendDevicePtr = pExtendDevices[index].lock();
        if (!extendDevicePtr) {
            strStream << ExtendDeviceEnum::NO_DEVICE.name;
        } else {
            strStream << extendDevicePtr->mdeviceType.name;
        }
        content[i + 1] = strStream.str();
    }

    screen.show(&content[0], &content[1], &content[2], &content[3]);

}
